package com.ygqh.baby.controller.os;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.ygqh.baby.po.AdminUser;
import com.ygqh.baby.shiro.utils.SessionUtil;

@Controller
public class CommonOsController {

	@RequestMapping("os/heartbeat")
	@ResponseBody
	public Map<String,Object> heartbeat(ModelMap model,HttpServletRequest request,HttpServletResponse response) throws Exception{	
		Map<String,Object> map = new HashMap<String, Object>();
		AdminUser user=SessionUtil.getCurrentUser();
		
		Boolean isAlive  = true;		
		if(user == null){
			isAlive = false;
			response.addHeader("loginStatus", "accessDenied");
			response.sendError(HttpServletResponse.SC_FORBIDDEN);
		}
		map.put("isAlive", isAlive);
		
		return map;	
	}
}
